package org.dromara.community.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.dromara.community.entity.AsComplaint;
import org.dromara.community.entity.dto.AsComplaintDTO;

import java.util.List;

@Mapper
public interface AsComplaintMapper extends BaseMapper<AsComplaint> {

    @Select("SELECT\n" +
        "\tc.id AS id,\n" +
        "\tc.complaintclassification_id,\n" +
        "\tc.url,\n" +
        "\tc.supplementary_explanation,\n" +
        "\tc.user_id,\n" +
        "\tc.complaint_time as complaintTime, \n" +
        "\tu.user_id AS user_id,\n" +
        "\tu.nick_name,\n" +
        "\tcat.id AS category_id,\n" +
        "\tcat.classification \n" +
        "FROM\n" +
        "\tas_complaint c\n" +
        "\tLEFT JOIN sys_user u ON c.user_id = u.user_id\n" +
        "\tLEFT JOIN as_complaintclassification cat ON c.complaintclassification_id = cat.id;\n" +
        "\t\n")
    List<AsComplaintDTO> selectAll();
}
